package org.vuzya.motivateme.helpers;

import org.vuzya.motivateme.R;
import org.vuzya.motivateme.core.BusinessListBinder;
import org.vuzya.motivateme.models.Businesses;

import android.content.Context;
import android.database.Cursor;
import android.widget.ListAdapter;
import android.widget.SimpleCursorAdapter;


public class AdapterHelper {
	public static ListAdapter getBusinessListAdapter(Context context, Cursor cursor, boolean isFinished){
		
		SimpleCursorAdapter adapter = new SimpleCursorAdapter(context, R.layout.business_list_item, cursor, 
           		new String[] { 
            		Businesses.TITLE,
            		Businesses.DESCRIPTION,
            		Businesses.START_DATE,
            		Businesses.FINISH_DATE
            	}, new int[] {
            		R.id.business_list_item_title,
            		R.id.business_list_item_description,
            		R.id.business_list_item_startdate,
            		R.id.business_list_item_finishdate
            	});
		if(!isFinished){
			adapter.setViewBinder(new BusinessListBinder());
		}
		return adapter;
	}
}
